From: Jyrki Gadinger Date: Thu, 17 Apr 2025 16:00:09 +0000 (+0200) Subject: fix(gui): handle invalid file name edge case on Windows X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1^2~13^2~1^2~35^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=18cbf2503185b4dc58864b524446e8f4502e2cf6;p=nextcloud-desktop.git fix(gui): handle invalid file name edge case on Windows File names like "c:blah" would break the usage of the dialogue, displaying a path like "c://blah" instead. Apparently `QDir::filePath` checks if the passed file name is an absolute file name using `!QFileInfo::isRelative`, which is the case if the second character in the string is a colon -- probably indicating a drive letter. Signed-off-by: Jyrki Gadinger --- diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index b39b354c4..9bd401859 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -694,8 +694,21 @@ void ActivityListModel::slotTriggerDefaultAction(const int activityIndex) ? InvalidFilenameDialog::InvalidMode::ServerInvalid : InvalidFilenameDialog::InvalidMode::SystemInvalid; +#ifdef Q_OS_WIN + // Edge case time! + // QDir::filePath checks whether the passed `fileName` is absolute (essentialy by using `!QFileInfo::isRelative()`). + // On Windows, if `fileName` starts with a letter followed by a colon (e.g. "A:BCDEF"), it is considered to be an + // absolute path. + // Since the complete desired path is required by InvalidFilenameDialog, catch that special case here and prefix it ourselves... + const auto filePath = activity._file.length() >= 2 && activity._file[1] == ':' + ? folder->path() + activity._file + : folderDir.filePath(activity._file); +#else + const auto filePath = folderDir.filePath(activity._file); +#endif + _currentInvalidFilenameDialog = new InvalidFilenameDialog(_accountState->account(), folder, - folderDir.filePath(activity._file), fileLocation, invalidMode); + filePath, fileLocation, invalidMode); connect(_currentInvalidFilenameDialog, &InvalidFilenameDialog::accepted, folder, [folder]() { folder->scheduleThisFolderSoon(); });